home *** CD-ROM | disk | FTP | other *** search
/ PC Joker 2000 December / PCJ1200CD2.ISO / JOKER95.EXE / JOKER95.dxr / Scripts_14_FileIO w-o dialogs.ls < prev    next >
Encoding:
Text File  |  2000-10-17  |  2.1 KB  |  66 lines

  1. property ReadOrWrite, whichevent, WhichFile, WhichField
  2.  
  3. on mouseUp me
  4.   if whichevent = #mouseUp then
  5.     init(me)
  6.   end if
  7. end
  8.  
  9. on mouseDown me
  10.   if whichevent = #mouseDown then
  11.     init(me)
  12.   end if
  13. end
  14.  
  15. on prepareFrame me
  16.   if whichevent = #prepareFrame then
  17.     init(me)
  18.   end if
  19. end
  20.  
  21. on enterFrame me
  22.   if whichevent = #enterFrame then
  23.     init(me)
  24.   end if
  25. end
  26.  
  27. on exitFrame me
  28.   if whichevent = #exitFrame then
  29.     init(me)
  30.   end if
  31. end
  32.  
  33. on init me
  34.   if objectp(myfile) then
  35.     set myfile to 0
  36.   end if
  37.   set myfile to new(xtra("fileio"))
  38.   case the ReadOrWrite of me of
  39.     "Read from File into Field":
  40.       openFile(myfile, the applicationPath & the WhichFile of me, 0)
  41.       set theFile to readFile(myfile)
  42.       put theFile into field the WhichField of me
  43.     "Write to File from Field":
  44.       openFile(myfile, the applicationPath & the WhichFile of me, 0)
  45.       delete(myfile)
  46.       createFile(myfile, the applicationPath & the WhichFile of me)
  47.       openFile(myfile, the applicationPath & the WhichFile of me, 0)
  48.       setFinderInfo(myfile, "TEXT ttxt")
  49.       writeString(myfile, the text of member the WhichField of me)
  50.     "Delete File":
  51.       openFile(myfile, the applicationPath & the WhichFile of me, 0)
  52.       delete(myfile)
  53.   end case
  54.   closeFile(myfile)
  55.   set myfile to 0
  56. end
  57.  
  58. on getPropertyDescriptionList
  59.   set p_list to [#whichevent: [#comment: "Initializing Event:", #format: #symbol, #range: [#mouseUp, #mouseDown, #prepareFrame, #enterFrame, #exitFrame], #default: #mouseUp], #ReadOrWrite: [#comment: "Function:", #format: #string, #default: "Read", #range: ["Read from File into Field", "Write to File from Field", "Delete File"]], #WhichFile: [#comment: "Filename:", #format: #string, #default: ".txt"], #WhichField: [#comment: "Field Name", #format: #field, #default: member 1]]
  60.   return p_list
  61. end
  62.  
  63. on getBehaviorDescription
  64.   return "This behavior will:" & RETURN & "*** Read a file into a field" & RETURN & "*** Write a field to a file" & RETURN & "*** Delete a file" & RETURN & "This behavior assumes that file is " & RETURN & "located in the same folder as the projector/Director"
  65. end
  66.